package com.epu.itepu.adapters;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.epu.itepu.helper.Variables;

public class PhotoPagerAdapter extends PagerAdapter{
	
	Context mContext = null;
	
	public PhotoPagerAdapter(Context _context) {
		this.mContext = _context;
	}
	
	@Override
	public int getCount() {
		return Variables.listPhotos.size();
	}

	@Override
	public boolean isViewFromObject(View view, Object object) {
		return view == ((ImageView) object);
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		ImageView imageView = new ImageView(mContext);
		imageView.setImageBitmap(Variables.listPhotos.get(position));
        ((ViewPager) container).addView(imageView, 0);
		return imageView;

	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		((ViewPager) container).removeView((ImageView) object);
	}

}
